/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/reverse-integer
   @Language: C++
   @Datetime: 19-05-21 16:21
   */

class Solution {
public:
	int reverse(int x) {
		char tmp[32];
		sprintf(tmp,"%d",x);
		std::reverse(tmp+(tmp[0]=='-'?1:0),tmp+strlen(tmp));
		long r=atol(tmp);
		if(r>INT_MAX || r<INT_MIN) return 0;
		else return r;
	}
};
